<template>
	<div>
		<!-- <mt-field  placeholder="请输入名称"  v-model="update_arr.username"></mt-field> -->
        <setHeader :title="headerTitle" :back-fn="goback"></setHeader>
        <div class="pagecontent">
            <!-- v-for="item in companylist" :key="item.id" v-on:click="UpdateCompany(item.company_id)" -->
            <div class="main-company-change" v-for="item in companylist" :key="item.id" @click="UpdateCompany(item.company_id)">
                <!-- <mt-cell :title="item.name" is-link></mt-cell> -->
                <!-- <mt-field placeholder="请输入名称" v-model="item.name" readonly="readonly"></mt-field> -->
                {{item.name}}
            </div>
        </div>
	</div>
</template>
<script>
import setHeader from '../public/setHeader.vue';
import { MessageBox } from 'mint-ui';
import qs from 'qs';

export default {

	data() {
      return {
        // username: '',
        // userInfo:'',
        headerTitle:'展示公司',
        update_arr:[
            {
                // cid:'',
                // access_token:'',
            }
        ],
        companylist: ''
        // companylist: [
        //     {
        //         companyName: '广东耐思智慧有限公司'
        //     }
        // ]
      };
    },
    components: {
		setHeader,
	},
    mounted() {
    	let that = this;
        // that.update_arr.access_token = window.localStorage.getItem('access_token');
        let arr = [];
        arr.access_token = window.localStorage.getItem('access_token');
        // console.log(that.update_arr);
        that.$post(that.$path+'/index.php/api/companylist',arr).then((response) => { 
                        console.log('arr',arr);
                        if(response.code == 200){ 
                             // that.$router.push({path:'/userUpdate'});
                             that.companylist = response.data;
                            //  console.log(response.data[0].name)
                        }else{ 
                             that.$router.push({path:'/companyCreate'});
                        }
                })
    },
    methods:{
        UpdateCompany:function(c_id){ 
            let that = this;
            that.update_arr.access_token = window.localStorage.getItem('access_token');
            if(c_id){ 
                that.update_arr.c_id = c_id;
                that.$post(that.$path+'/index.php/api/company',that.update_arr).then((response) => { 
                    if(response.code == 200){ 
                        that.$router.push({path:'/userUpdate'});
                    }
                }) 
            }
            that.$emit('UpdateCompanydone')
        },
        goback() {
            this.$emit('done');
        }
    },
    props: ['done', 'UpdateCompanydone']
}

</script>

<style >
/* .el-long-create-button{
	margin-top:50px;
} */

.main-company-change {
    width: 100%;
    height: 1rem;
    line-height: 1rem;
    background-color: #fff;
    font-size: 0.26rem;
    color: #333;
    border-bottom: 1px solid #d8d8d8;
    text-align: left;
    padding-left: 0.2rem;
}
/* .main-company-change .mint-cell-title {
    padding-left: 0.2rem;
}
.main-company-change .mint-cell-allow-right::after {
    border: 0;
} */
</style>